/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function Dialog(title, message, options, callback, target) {
    this.title = title;
    this.options = options;
    $("<div class='modal-dialog-layer'>&nbsp;</div>").appendTo(document.body);
    this.dialog = $("<div class='modal-dialog'>"
            + "<div class='header'><div class='title'>" + title + "</div></div>"
            + "<div class='dialog-content'>" + message + "</div>"
            + "<div class='dialog-buttons'></div>"
        + "</div>").appendTo(document.body);

    for (var i = 0; i < options.length; i++) {
        var button = $("<div class='dialog-button'>" + options[i] + "</div>").appendTo(this.dialog.find('.dialog-buttons'));
        button[0].index = i;
        button[0].dialog = this;
        button.click(function() {
            $(".modal-dialog-layer").detach();
            $(".modal-dialog").detach();
            
            if (callback) {
                callback(this.index);
            } 
        });
    }        
}